﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq;

namespace SkypeTranslater
{
	internal sealed class RecoveryModule
	{
		public static void RecoveryGroupsXml(string filePath)
		{
			if (System.IO.File.Exists(filePath))
				return;

			App.Log.Info("Begin recovering of Groups.xml");
			XDocument doc = new XDocument();
			doc.Declaration = new XDeclaration("1.0", "utf-8", "yes");
			doc.Add(new XElement("Groups"));
			doc.Save("D:\\1.xml");

			System.IO.FileInfo fi = new System.IO.FileInfo(filePath);
			if (fi.Exists && (fi.Attributes & System.IO.FileAttributes.ReadOnly) != 0)
			{
				App.Log.Info("Changing file attribute");
				fi.Attributes = System.IO.FileAttributes.Normal;
			}

			App.Log.Info("File recovered successfully");
		}
	}
}
